package com.at.bigdata.spark.core.hc.aviator;

import com.googlecode.aviator.runtime.function.AbstractFunction;
import com.googlecode.aviator.runtime.function.FunctionUtils;
import com.googlecode.aviator.runtime.type.AviatorDouble;
import com.googlecode.aviator.runtime.type.AviatorObject;

import java.util.Map;

/**
 * @author cdhuangchao3
 * @date 2023/4/26 4:18 PM
 */
public class MultiplicationFunc extends AbstractFunction {
    @Override
    public String getName() {
        return "multiplication";
    }

    @Override
    public AviatorObject call(Map<String, Object> env, AviatorObject arg1, AviatorObject arg2) {
        Number num1 = FunctionUtils.getNumberValue(arg1, env);
        Number num2 = FunctionUtils.getNumberValue(arg2, env);
        // 乘法
        return new AviatorDouble(num1.doubleValue() * num2.doubleValue());
    }

}
